package com.cy2;
/*
本测试用于测试，键为String类型，值为Student类型，不用保证键的唯一性
 */
import java.util.HashMap;
import java.util.Map;

public class HashMapDemo {
    public static void main(String[] args) {
        HashMap<String, Student> hp = new HashMap<>();
        Student s1 = new Student("林青霞", 30);
        Student s2 = new Student("张曼玉", 50);
        Student s3 = new Student("王祖贤", 18);

        hp.put("200123",s1);
        hp.put("12138",s2);
        hp.put("79513",s3);
        for (String s : hp.keySet()) {
            String s4 = s;
            Student s5 = hp.get(s4);
            System.out.println(s5.getName()+","+s5.getAge());
        }
        System.out.println("-----------------");
        for (Map.Entry<String, Student> stringStudentEntry : hp.entrySet()) {
            Map.Entry<String, Student> stringStudentEntry1 = stringStudentEntry;
            System.out.println(stringStudentEntry1.getKey()+","+stringStudentEntry1.getValue());
        }


    }
}
